const App = {
    data() {
        return {
            tableData:[],
            form: {
                isCommentNull:'0',
                keepState:'0',
                Data:'',
                Page: 1, //页码
                Limit: 20
            },
            Total:0,
            loading:false,
        }
    },
    mounted() {
        const tableForm = localStorage.getItem("tableForm");
        if (tableForm) {
            this.form = JSON.parse(tableForm);
        }
        this.postgetList(this.form);
    },
    methods: {
        check(){
            if (this.form.keepState == '1') {
                localStorage.setItem('tableForm',JSON.stringify(this.form));
            } else {
                localStorage.removeItem('tableForm')
            }
            this.postgetList(this.form)
        },
        reset() {
            window.location.reload();
        },
        handleSizeChange(newSize) {
            this.form.Page = 1;
            this.form.Limit = newSize;
            if (this.form.keepState == '1') {
                localStorage.setItem('tableForm',JSON.stringify(this.form));
            } else {
                localStorage.removeItem('tableForm')
            }
            this.postgetList(this.form);
        },
        handleCurrentChange(newPage) {
            this.form.Page = newPage;
            if (this.form.keepState == '1') {
                localStorage.setItem('tableForm',JSON.stringify(this.form));
            } else {
                localStorage.removeItem('tableForm')
            }
            this.postgetList(this.form);
        },
        postgetList(data) {
            this.loading = true;
            $.ajax({
                headers: {
                    "content-type": "application/x-www-form-urlencoded",
                    "Session":'session5'
                },
                url: `${y}/generalPaginationQueryTableNameDetail`,
                method: "get",
                data,
                success: (res) => {
                    this.Total = res.Total;
                    this.tableData = res.Data;
                },
                complete: () =>{
                    this.loading = false;
                }
            });
        },
        personalAdd() {
            sessionStorage.setItem("Url", "");
            window.location.href = './sql_config.html?action=Add'
        },
        handleEdit(row) {
            window.location.href = "./edit.html?nodeKey=" + row.TABLE_NAME;
        },
        handleShow(row){
            window.location.href = './show.html?nodeKey=' + row.TABLE_NAME
        },
        handleDetail(row){
            sessionStorage.setItem("formData",JSON.stringify(row))
            window.location.href = './detail.html?nodeKey=' + row.TABLE_NAME;
        }
    },
};



const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus,{locale: zhCn});
app.mount("#app");
